package net.loyintean.pearlshell.wechat.distribute.impl;

import net.loyintean.pearlshell.wechat.common.MessageTypeEnum;
import net.loyintean.pearlshell.wechat.distribute.IMessageDistributor;
import net.loyintean.pearlshell.wechat.model.BaseMessageModel;
import net.loyintean.pearlshell.wechat.model.common.TextMessageModel;
import net.loyintean.pearlshell.wechat.service.IMessageProcesser;
import net.loyintean.pearlshell.wechat.service.iran.IranMessageProcceserImpl;

public class IranDistributorImpl implements IMessageDistributor {

	private static final String distributeKey = "IRAN";

	private IMessageProcesser processer = new IranMessageProcceserImpl();

	@Override
	public IMessageProcesser distribute(BaseMessageModel message) {

		assert message != null;

		TextMessageModel textMessage;

		if (MessageTypeEnum.text.equals(message.getMsgType())) {
			textMessage = (TextMessageModel) message;
		} else {
			textMessage = null;
		}

		if (textMessage != null
				&& distributeKey.equals(textMessage.getContent().toUpperCase())) {
			return processer;
		} else {
			return null;
		}
	}

}
